var stationobj = require("./query.js").array;
module.exports = {
  initTrain : (ress) => {
    let lists = [];
    ress.forEach((item, index) => {
      let list = {};
      list.train_id = item.split("|")[2];
      list.train_no = item.split("|")[3];
  
      for (var key in stationobj) {
        if (stationobj[key] === item.split("|")[6]) {
          list.from_station_name = key;
          list.from_station_code = item.split("|")[6];
        }
        if (stationobj[key] === item.split("|")[7]) {
          list.to_station_name = key;
          list.to_station_code = item.split("|")[7];
        }
      }
      list.start_time = item.split("|")[8];
      list.end_time = item.split("|")[9];
      list.duration = item.split("|")[10].split(":")[0] + ":" + item.split("|")[10].split(":")[1] ;
      list.leave_time = item.split("|")[13];
      list.to_station_no = item.split("|")[17];
      list.children = [];
      list.goList = [];
      list.backList = [];
      //[31]---->一等座：sit_1
      list.sit_1 = item.split("|")[31]
      //[30]---->二等座：sit_2
      list.sit_2 = item.split("|")[30]
      //[29]---->硬座：sit_h
      list.sit_h = item.split("|")[29]
      //[26]---->无座：sit_0
      list.sit_0 = item.split("|")[26]
      //[28]---->硬卧：bed_h
      list.bed_h = item.split("|")[28]
      //[23]---->软卧：bed_s
      list.bed_s = item.split("|")[23] 


      lists.push(list);
    });
    return lists;
  }
}